interface IAdminState {
  adminname: string
  token: string
  role: number
  isLogin: boolean
}

export default {
  namespaced: true,
  state: {
    // adminname: '',
    // token: '',
    // role: 0
    adminname: localStorage.getItem('adminname') || '',
    token: localStorage.getItem('token') || '',
    role: Number(localStorage.getItem('role')),
    isLogin: localStorage.getItem('isLogin') === 'true'
  },
  mutations: {
    CHANGE_ADMIN_NAME (state: IAdminState, payload: string) {
      state.adminname = payload
    },
    CHANGE_TOKEN (state: IAdminState, payload: string) {
      state.token = payload
    },
    CHANGE_ROLE (state: IAdminState, payload: number) {
      state.role = payload
    },
    CHANGE_IS_LOGIN (state: IAdminState, payload: boolean) {
      state.isLogin = payload
    }
  }
}
